package com.sys.app.cms;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

public class IdPassword {
	static public void saveIdPassword(String id, String password, Context context) {
		SharedPreferences sharedPreferences = context.getSharedPreferences("cookie", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        
        editor.putString("id", id);
        editor.putString("password", password);
        editor.commit();
	}
	
	static public String getId(Context context) {
		SharedPreferences sharedPreferences = context.getSharedPreferences("cookie", Context.MODE_PRIVATE);
		return sharedPreferences.getString("id", "");
	}
	
	static public String getPassword(Context context) {
		SharedPreferences sharedPreferences = context.getSharedPreferences("cookie", Context.MODE_PRIVATE);
		return sharedPreferences.getString("password", "");
	}
	
	static public boolean haveIdPassword(Context context) {
		if(TextUtils.isEmpty(getId(context)) || TextUtils.isEmpty(getPassword(context))) {
			return false;
		} else {
			return true;
		}
	}

}
